package online.shenjian.mq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

@Component
@ConditionalOnProperty(name = "spring.rabbitmq.enable", matchIfMissing = true)
public class TopicSender {

    private RabbitTemplate rabbitTemplate;

    public TopicSender(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    public void send() {
        rabbitTemplate.convertAndSend("topic", "asia.china.beijing", "asia.china.beijing");
        rabbitTemplate.convertAndSend("topic", "asia.china.nanjing", "asia.china.nanjing");
        rabbitTemplate.convertAndSend("topic", "asia.china", "asia.china");
    }
}
